<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        {% raw %}
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 100%;
            padding: 20px;
            margin: 0;
        }
        pre {
            background-color: #f5f5f5;
            padding: 10px;
            border-radius: 5px;
            overflow-x: auto;
        }
        code {
            font-family: Consolas, Monaco, 'Andale Mono', monospace;
            background-color: #f5f5f5;
            padding: 2px 4px;
            border-radius: 3px;
        }
        blockquote {
            border-left: 4px solid #ddd;
            padding-left: 16px;
            margin-left: 0;
            color: #666;
        }
        img {
            max-width: 100%;
        }
        table {
            border-collapse: collapse;
            width: 100%;
            margin-bottom: 16px;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        .user-message {
            background-color: #f0f7ff;
            padding: 10px 15px;
            border-radius: 8px;
            margin-bottom: 15px;
        }
        .assistant-message {
            background-color: #f9f9f9;
            padding: 10px 15px;
            border-radius: 8px;
            margin-bottom: 15px;
        }
        .mermaid {
            text-align: center;
        }
        {% endraw %}
    </style>
    <script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
    <script>
        {% raw %}
        document.addEventListener('DOMContentLoaded', function() {
            mermaid.initialize({
                startOnLoad: true,
                theme: 'default',
                securityLevel: 'loose',
                flowchart: { useMaxWidth: true }
            });
        });
        
        // 动态初始化新添加的mermaid图表
        function initMermaid() {
            mermaid.init(undefined, document.querySelectorAll('.mermaid'));
        }
        
        // 滚动到底部
        function scrollToBottom() {
            if (document.body) {
                window.scrollTo(0, document.body.scrollHeight);
            }
        }
        {% endraw %}
    </script>
</head>
<body>
    <div id="content">
        {{ content }}
    </div>
    <script>
        {% raw %}
        // 初始化页面后执行
        window.onload = function() {
            initMermaid();
            scrollToBottom();
        };
        {% endraw %}
    </script>
</body>
</html>